﻿#region Copyright(C) 2018 FI Ltd. All rights reserved.
// ==================================================================================================
// Copyright(C) 2018 FI Ltd. All rights reserved.
//
// SYSTEM NAME	    : FI.Net Application Framework
// COMPONENT ID	    : FI.Core
// COMPONENT DESC   : FI.Net Core Foundation
//
// CREATED DATE/BY  : 18 Aug 2018 / Tian Mi
//
// REVISION HISTORY :	
// DATE/BY			SR#/CS/PM#/OTHERS		DESCRIPTION OF CHANGE
// ==================================================================================================
#endregion

namespace FI.Core.Caching
{
    /// <summary>
    /// The priority of the cache item.
    /// </summary>
    public enum CacheItemPriority
    {
        /// <summary>
        /// Not specified.
        /// </summary>
        None,

        /// <summary>
        /// The low priority.
        /// </summary>
        Low,

        /// <summary>
        /// The normal priority
        /// </summary>
        Normal,

        /// <summary>
        /// The high priority.
        /// </summary>
        High
    }

    /// <summary>
    /// This class is used to defined extension methods apecific to <see cref="CacheItemPriority"/>.
    /// </summary>
    public static class CacheItemPriorityExtensions
    {
        /// <summary>
        /// Convert to <see cref="System.Web.Caching.CacheItemPriority"/>.
        /// </summary>
        /// <param name="priority">The priority.</param>
        /// <returns>The <see cref="System.Web.Caching.CacheItemPriority"/>.</returns>
        public static System.Web.Caching.CacheItemPriority ToWebCacheItemPriority(this CacheItemPriority priority)
        { 
            switch(priority)
            {
                case CacheItemPriority.None: return System.Web.Caching.CacheItemPriority.Default;
                case CacheItemPriority.Low: return System.Web.Caching.CacheItemPriority.Low;
                case CacheItemPriority.Normal: return System.Web.Caching.CacheItemPriority.Normal;
                default: return System.Web.Caching.CacheItemPriority.High;
            }
        }
    }

}
